import { Component, OnInit } from '@angular/core';
import { _HttpClient } from '@delon/theme';
import { NzMessageService } from 'ng-zorro-antd/message';
import { NzModalRef } from 'ng-zorro-antd/modal';

@Component({
  selector: 'app-imageview',
  templateUrl: './imageview.component.html',
  styleUrls: ['./imageview.less'],
})
export class ImageViewComponent implements OnInit {
  params: any = {};
  currentIndex = 0;
  constructor(private modal: NzModalRef, public msgSrv: NzMessageService, public http: _HttpClient) {}

  ngOnInit(): void {
    this.currentIndex = this.params.index;
  }

  close() {
    this.modal.destroy();
  }
  prevImg() {
    if (this.currentIndex === 0) {
      this.msgSrv.error('已经是第一张图片！');
      return false;
    }
    this.currentIndex--;
    return true;
  }
  nextImg() {
    if (this.currentIndex === this.params.imgList.length - 1) {
      this.msgSrv.error('已经是最后一张图片！');
      return false;
    }
    this.currentIndex++;
    return true;
  }
}
